home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "Custom Cursor DLL Demo"
- Height = 4680
- Icon = FORM1.FRX:0000
- Left = 1020
- LinkTopic = "Form1"
- ScaleHeight = 3990
- ScaleWidth = 7365
- Top = 1155
- Width = 7485
- Begin CommandButton Command1
- Caption = "Command1"
- Height = 495
- Left = 3000
- TabIndex = 0
- Top = 2880
- Width = 1215
- End
- Begin Menu mnuFile
- Caption = "&File"
- Begin Menu mnuFilePrint
- Caption = "&Print"
- End
- Begin Menu mnuFileSeperator1
- Caption = "-"
- End
- Begin Menu mnuFileExit
- Caption = "&Exit"
- Shortcut = {F4}
- End
- End
- Begin Menu mnuEdit
- Caption = "&Edit"
- Begin Menu mnuEditCut
- Caption = "Cu&t"
- Shortcut = ^X
- End
- Begin Menu mnuEditCopy
- Caption = "&Copy"
- Shortcut = ^C
- End
- Begin Menu mnuEditPaste
- Caption = "&Paste"
- Shortcut = ^V
- End
- End
- Begin Menu mnuDraw
- Caption = "&Draw"
- Begin Menu mnuDrawLine
- Caption = "&Line"
- End
- Begin Menu mnuDrawCircle
- Caption = "&Circle"
- End
- Begin Menu mnuDrawFreehand
- Caption = "&Freehand"
- End
- Begin Menu mnuDrawPaint
- Caption = "&Paint"
- End
- End
- Begin Menu mnuHelp
- Caption = "&Help"
- Begin Menu mnuHelpContext
- Caption = "&Context Help"
- Shortcut = {F1}
- End
- Begin Menu mnuHelpSeperator1
- Caption = "-"
- End
- Begin Menu mnuHelpAbout
- Caption = "&About ..."
- End
- End
- ' These are the Windows API functions that need to be declared and called
- ' in order to use CURSOR.DLL. Each must be entered on single line and be
- ' typed in exactly as shown.
- ' LoadLibrary: lpLibFileName is the name of the DLL you are trying to load.
- ' in this case it will be CURSOR.DLL when the function is called
- ' in the FormLoad Procedure.
- ' LoadCursor: hInstance a pointer to the CURSOR.DLL, this will be returned
- ' from the LoadLibrary function. lpCursorName is the name of the
- ' cursor that you want to load. A list of the cursor contained
- ' in CURSOR.DLL is given in the help file provided with CUSTOM
- ' CURSOR DLL. This must be called once for each cursor you wish
- ' to load. It can be called from any point in the program.
- ' SetClassWord: hWnd is the window handle returned by Windows for a Form or
- ' object. nIndex is a constant, this is defined below (GCW_HCURSOR)
- ' wNewWord will be the variable to which you saved a custom cursor
- ' handle. This function needs to be called whenever you want to
- ' change the current cursor to a new one that has previously been
- ' loaded with the LoadCursor function.
- ' DestroyCursor:hCursor will be the variable that you saved a custom cursor in
- ' when you loaded it with LoadCursor. The API function should be
- ' called when you exit the program so that each custom cursor that
- ' has been defined can be removed from system memory.
- ' NOTE: You should not use the DestroyCursor function unless you have
- ' created the cursor with the CreateCursor API function. This
- ' function is not used but was left in this demonstration in
- ' case you required it for your application.
- ' FreeLibrary: hLibModule will be the variable that you saved the return value
- ' from LoadLibrary. This API function needs to be called when
- ' you exit a program that loads CURSOR.DLL with the LoadLibrary function.
- Declare Function LoadLibrary Lib "Kernel" (ByVal lpLibFileName As String) As Integer
- Declare Function LoadCursor Lib "User" (ByVal hInstance As Integer, ByVal lpCursorName As Any) As Integer
- Declare Function SetClassWord Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer, ByVal wNewWord As Integer) As Integer
- Declare Function DestroyCursor Lib "User" (ByVal hCursor As Integer) As Integer
- Declare Sub FreeLibrary Lib "Kernel" (ByVal hLibModule As Integer)
- ' Constant and variable declarations
- Const GCW_HCURSOR = (-12)
- Dim CurCustom1
- Dim CurCustom2
- Dim CurCustom3
- Dim CurCustom4
- Dim CurCustom5
- Dim CurCustom6
- Dim CurCustom7
- Dim CurCustom8
- Dim CurCustom9
- Dim CurCustom10
- Dim SysCursor
- Dim DLLInstance
- Dim CommandCursor
- Sub Form_Load ()
- ' Written by: Robert B. Cooper
- ' ELECTRON Software
- ' P.O. Box 309
- ' Mt. Storm, WV. 26739
- ' CompuServe ID#: 73244,3472
- ' America OnLine: ELECTRON
- ' The Visual Basic files for the Custom Cursor DLL Demonstration were
- ' written with VB version 2.0.
- ' You have a royalty-free right to use, modify, reproduce and distribute the
- ' Visual Basic sample filesprovided that you agree that ELECTRON SOFTWARE has
- ' no warranty obligations or liability for any Sample Application Files which
- ' are modified.
- ' Call the LoadLibrary Function to load the CURSOR DLL into memory.
- ' The returned handle is then stored in DLLInstance.
- DLLInstance = LoadLibrary("CURSOR.DLL")
- ' The next 10 lines load each cursor to be used.
- ' The returned handle is stored in the variable CurCustom(1 - 10)
- CurCustom1 = LoadCursor(DLLInstance, "POINTER_NW")
- CurCustom2 = LoadCursor(DLLInstance, "PRINTER")
- CurCustom3 = LoadCursor(DLLInstance, "SCISSORS_NW")
- CurCustom4 = LoadCursor(DLLInstance, "HAND_DRAG_1")
- CurCustom5 = LoadCursor(DLLInstance, "PIN_NW")
- CurCustom6 = LoadCursor(DLLInstance, "DRAW_LINE")
- CurCustom7 = LoadCursor(DLLInstance, "DRAW_CIRCLE")
- CurCustom8 = LoadCursor(DLLInstance, "DRAW_FREEHAND")
- CurCustom9 = LoadCursor(DLLInstance, "PAINT_BRUSH_SW")
- CurCustom10 = LoadCursor(DLLInstance, "CONTEXT_HELP")
- ' The SetClassWord Function needs to be called to change the presently
- ' loaded cursor to a new cursor.
- ' The 0-Default cursor MUST BE set on each Form and Control that you want
- ' to use a custom cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom1)
- ' This next line ensures that the POINTER_NW Custom Cursor is always
- ' shown when the mouse is over the Command Button.
- CommandCursor = SetClassWord(Command1.hWnd, GCW_HCURSOR, CurCustom1)
- End Sub
- Sub Form_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
- ' This section restores the POINTER_NW Custom Cusor when the right mouse
- ' button is pressed and released.
- If Button = 2 Then
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom1)
- End If
- End Sub
- Sub Form_Unload (Cancel As Integer)
- ' Call the FreeLibrary API function to remove CURSOR.DLL from memory.
- Call FreeLibrary(DLLInstance)
- End Sub
- Sub mnuDrawCircle_Click ()
- ' Changes the Cursor to the DRAW_CIRCLE Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom7)
- End Sub
- Sub mnuDrawFreehand_Click ()
- ' Changes the Cursor to the DRAW_FREEHAND Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom8)
- End Sub
- Sub mnuDrawLine_Click ()
- ' Changes the Cursor to the DRAW_LINE Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom6)
- End Sub
- Sub mnuDrawPaint_Click ()
- ' Changes the Cursor to the DRAW_PAINT Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom9)
- End Sub
- Sub mnuEditCopy_Click ()
- ' Changes the Cursor to the HAND_DRAG_1 Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom4)
- End Sub
- Sub mnuEditCut_Click ()
- ' Changes the Cursor to the SCISSORS Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom3)
- End Sub
- Sub mnuEditPaste_Click ()
- ' Changes the Cursor to the PIN_NW Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom5)
- End Sub
- Sub mnuFileExit_Click ()
- ' Unloads Form1, executes the code located in the FORM.UNLOAD procedure
- ' and exits the program.
- Unload Form1
- End
- End Sub
- Sub mnuFilePrint_Click ()
- ' Changes the Cursor to the PRINTER Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom2)
- End Sub
- Sub mnuHelpAbout_Click ()
- ' The About Dialog Box has its cursor set to the default arrow cursor
- ' provided by the windows enviroment. This is accomplished by setting
- ' the MousePointer Property to 1-Arrow. Remember to be able to use a
- ' custom cursor you must set the MousePointer property to 0-default.
- ABOUT.Show 1
- End Sub
- Sub mnuHelpContext_Click ()
- ' Changes the Cursor to the HELP_CONTEXT Custom Cursor.
- SysCursor = SetClassWord(Form1.hWnd, GCW_HCURSOR, CurCustom10)
- End Sub
-